Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16409 do not use receive step to determine root report #16723

Merged

Conversation

jack-h-wang
Copy link
Collaborator

@jack-h-wang jack-h-wang commented Dec 5, 2024

This PR adjusts the search for root reports to not rely on explicitly searching for the receive step report. Additionally, the root report from the submissions endpoint should now include the sender-supplied payloadname if present.

Test Steps:

  1. The tests in ReportGraphTest and FhirTranslatorIntegrationTests are sufficient

Changes

  • Do not use receive step as indicator of a root report.
    • Instead, a root report is determined by a report ID that does not appear in the report_lineage table as a child report.
  • Retrieve payloadname from submission endpoint message headers when creating root report.

Checklist

Testing

  • Tested locally?
  • Ran ./prime test or ./gradlew testSmoke against local Docker ReportStream container?
  • (For Changes to /frontend-react/...) Ran npm run lint:write?
  • Added tests?

Linked Issues

Copy link

github-actions bot commented Dec 5, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

Copy link

github-actions bot commented Dec 5, 2024

Test Results

1 258 tests  +2   1 254 ✅ +2   7m 27s ⏱️ -10s
  164 suites ±0       4 💤 ±0 
  164 files   ±0       0 ❌ ±0 

Results for commit 5e8a3c3. ± Comparison against base commit 986d6fb.

This pull request removes 2 and adds 4 tests. Note that renamed tests count towards both.
gov.cdc.prime.router.fhirengine.azure.FHIRTranslatorIntegrationTests ‑ successfully translate HL7 for FHIR receiver when isSendOriginal is true()
gov.cdc.prime.router.fhirengine.azure.FHIRTranslatorIntegrationTests ‑ successfully translate for FHIR receiver when isSendOriginal is true()
gov.cdc.prime.router.fhirengine.azure.FHIRTranslatorIntegrationTests ‑ successfully translate HL7 for FHIR receiver when isSendOriginal is true from convert step()
gov.cdc.prime.router.fhirengine.azure.FHIRTranslatorIntegrationTests ‑ successfully translate HL7 for FHIR receiver when isSendOriginal is true from receive step()
gov.cdc.prime.router.fhirengine.azure.FHIRTranslatorIntegrationTests ‑ successfully translate for FHIR receiver when isSendOriginal is true from convert step()
gov.cdc.prime.router.fhirengine.azure.FHIRTranslatorIntegrationTests ‑ successfully translate for FHIR receiver when isSendOriginal is true from receive step()

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Dec 5, 2024

Integration Test Results

 60 files  ±0   60 suites  ±0   36m 59s ⏱️ -15s
424 tests ±0  414 ✅ ±0  10 💤 ±0  0 ❌ ±0 
427 runs  ±0  417 ✅ ±0  10 💤 ±0  0 ❌ ±0 

Results for commit 5e8a3c3. ± Comparison against base commit 986d6fb.

♻️ This comment has been updated with latest results.

@jack-h-wang jack-h-wang added the platform Platform Team label Dec 6, 2024
@jack-h-wang jack-h-wang force-pushed the platform/jwang/16409-query-root-report-without-receive branch from 5c35630 to 4f56b4b Compare December 9, 2024 17:21
@jack-h-wang jack-h-wang marked this pull request as ready for review December 11, 2024 03:37
@jack-h-wang jack-h-wang requested a review from a team as a code owner December 11, 2024 03:37
@@ -178,7 +180,8 @@ class FHIRConverter(
// is properly recorded in the report file table with the correct sender
actionHistory.trackExternalInputReport(
report,
BlobAccess.BlobInfo(format, blobUrl, blobDigest.toByteArray())
BlobAccess.BlobInfo(format, blobUrl, blobDigest.toByteArray()),
payloadName
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change to carry over payloadname from the submissions API is needed to continue supporting the sendOriginal function. This adds the information to the root report being created here.

.leftJoin(REPORT_LINEAGE)
.on(REPORT_FILE.REPORT_ID.eq(REPORT_LINEAGE.CHILD_REPORT_ID))
.where(REPORT_LINEAGE.PARENT_REPORT_ID.isNull())
.orderBy(REPORT_FILE.ACTION_ID.asc())
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous query was to join the action table in order to check if the action_name is receive. The new query instead filters the list of reports to only include those that do not appear in report_lineage as a child. This list is then ordered by action_id to ensure the results are output in a consistent order. The join to the action table is removed since it is no longer necessary.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this explanation was very helpful!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify, we are now recursively going up the report lineage table until we find a parent report id which is null?

Copy link
Collaborator Author

@jack-h-wang jack-h-wang Dec 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The recursive query (cte) was not altered, but that is the current and previous behavior. The change here was in the way the results from the recursive query are filtered.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it 👍

@@ -798,4 +798,166 @@ class FHIRTranslatorIntegrationTests : Logging {
assertThat(translatedValue).isEqualTo(reportContents.toByteArray())
}
}

@Test
fun `successfully translate HL7 for FHIR receiver when isSendOriginal is true from convert step`() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests ensure sendOriginal items still function when convert is the root report, as the case would be when the submissions API is used.

Copy link
Collaborator

@JFisk42 JFisk42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good to the best of my understanding.
I ran the tests locally and everything is as expected.

Side note: I wanted to use this PR as an excuse to try out the new submission microservice. I was not able to get any reports sent to it because of setup issues. Most likely this is because of the extra steps currently required to get the authorization service running locally. This should no block this PR.

@@ -111,6 +111,7 @@ class FHIRConverter(
companion object {

private val clientIdHeader = "client_id"
private val payloadNameHeader = "payloadname"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need to be done now, but since in the future these header names will be used across multiple services they should be defined in the shared project. It makes it less prone to errors if we have to change them for some reason in the future.

Maybe you could throw a TODO on there with your ticket for submissions service updates.

@jack-h-wang jack-h-wang force-pushed the platform/jwang/16409-query-root-report-without-receive branch from b7c1982 to 5e8a3c3 Compare December 13, 2024 19:56
@jack-h-wang jack-h-wang merged commit 6cb62ec into main Dec 13, 2024
25 checks passed
@jack-h-wang jack-h-wang deleted the platform/jwang/16409-query-root-report-without-receive branch December 13, 2024 21:20
jack-h-wang added a commit that referenced this pull request Dec 18, 2024
jack-h-wang added a commit that referenced this pull request Dec 18, 2024
jack-h-wang added a commit that referenced this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform Platform Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Identify and update DB queries to be independent of the Receive step
3 participants